package gulimall.pojo.vo;

import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import java.util.StringJoiner;

/**
 * 购物项VO，表示购物车中的每一个购物项
 *
 * @author HLF
 * @date 2022/8/7 15:31
 * <p>
 * skuId:123123, // 商品id
 * check:true, // 是否选中
 * title:"apple phone", // 商品标题
 * defaultImage:'', // 商品默认显示的图片
 * price:4999, // 商品价格
 * count:1, // 商品数量
 * totalPrice:4999 // 购物车中选中商品总价格
 * skuSaleVo:{} //
 */
public class CartItemVO implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * skuId,商品
     */
    private Long skuId;

    /**
     * 是否选中,默认选中
     */
    private Boolean check = true;

    /**
     * 商品标题
     */
    private String title;

    /**
     * 商品默认显示的图片
     */
    private String defaultImg;

    /**
     * 商品价格
     */
    private BigDecimal price;

    /**
     * 商品数量
     */
    private Long count;

    /**
     * 商品总价格
     */
    private BigDecimal totalPrice;

    /**
     * 商品的属性
     */
    private List<String> skuAttr;


    /**
     * 计算购物项的总价格
     */
    public BigDecimal getTotalPrice() {
        return price.multiply(BigDecimal.valueOf(count));
    }


    public CartItemVO() {
    }

    public CartItemVO(Long skuId, Boolean check, String title, String defaultImg, BigDecimal price, Long count, BigDecimal totalPrice, List<String> skuAttr) {
        this.skuId = skuId;
        this.check = check;
        this.title = title;
        this.defaultImg = defaultImg;
        this.price = price;
        this.count = count;
        this.totalPrice = totalPrice;
        this.skuAttr = skuAttr;
    }

    public Long getSkuId() {
        return skuId;
    }

    public void setSkuId(Long skuId) {
        this.skuId = skuId;
    }

    public Boolean getCheck() {
        return check;
    }

    public void setCheck(Boolean check) {
        this.check = check;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDefaultImg() {
        return defaultImg;
    }

    public void setDefaultImg(String defaultImg) {
        this.defaultImg = defaultImg;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public Long getCount() {
        return count;
    }

    public void setCount(Long count) {
        this.count = count;
    }

    public void setTotalPrice(BigDecimal totalPrice) {
        this.totalPrice = totalPrice;
    }

    public List<String> getSkuAttr() {
        return skuAttr;
    }

    public void setSkuAttr(List<String> skuAttr) {
        this.skuAttr = skuAttr;
    }

    @Override
    public String toString() {
        return new StringJoiner(", ", CartItemVO.class.getSimpleName() + "[", "]")
                .add("skuId=" + skuId)
                .add("check=" + check)
                .add("title='" + title + "'")
                .add("defaultImg='" + defaultImg + "'")
                .add("price=" + price)
                .add("count=" + count)
                .add("totalPrice=" + totalPrice)
                .add("skuAttr=" + skuAttr)
                .toString();
    }
}
